package njupt.dbc;

import java.sql.Connection;
import java.sql.DriverManager;


public class DatabaseConnnection {
		//	public static final String DBDriver="oracle.jdbc.driver.OracleDriver";
		  //  public static final String DBUrl="jdbc:oracle:thin:@127.0.0.1:1521:xe";
		   // public static final String DBUser="leon";
		    //public static final String DBPassword="12345678";
    private Connection conn=null;
    public DatabaseConnnection() throws Exception{
    	try{
    		Class.forName("oracle.jdbc.driver.OracleDriver");
    		String DBUrl="jdbc:oracle:thin:@127.0.0.1:1521:xe";
    		this.conn=DriverManager.getConnection(DBUrl,"leon","12345678");
    		if(conn!=null){
    			System.out.println("connection success!");
    		}
    	}catch(Exception e){
    		throw e ;
    	}
    }	
    public Connection getConnection(){
    	return this.conn;
    }
    public void close() throws Exception{
    	if(this.conn!=null){
    		try{
    			this.conn.close();
    		}catch(Exception e){
    			throw e;
    		}
    	}
    }
} 
